#include "NetworkManagePage.h"
#include "LoopScheduler.h"


void NetworkManagePage::paint() {
    if (focus) {
        super::paint();
    } else {
        std::string content[4];
        if (0 == mmultiPageNo) {
            resetStream();
            strStream << "networkManage" << std::right << std::setw(3) << pageNum;
            content[0] = strStream.str();

            resetStream();
            strStream << "status:" << (SystemStatus::ONLINE == LoopSchedulerSingleton::instance().msystemStatus ? "online" : "connectin" );// << std::setw(3)
            content[1] = strStream.str();

            resetStream();
            strStream << "mode:" << networkModeVector->at(mnetworkManager.mtype);// << std::setw(3)
            if (NetworkType::AUTO == mnetworkManager.mtype){
                strStream << '-' << mnetworkManager.mpactiveNetwork->mname;
            }
            content[2] = strStream.str();

            resetStream();
            strStream << "signal:" << std::left << std::setw(9) << mnetworkManager.mpactiveNetwork->getSignalStrength();// << std::setw(3)
            content[3] = strStream.str();


        } else {
            INetwork* pnetwork = nullptr;
            if (1 == mmultiPageNo) {
                pnetwork = &mnetworkManager.methernet;

            } else if (2 == mmultiPageNo) {
                pnetwork = &mnetworkManager.mlte4gNetwork;

            } else {
                pnetwork = &mnetworkManager.methernet1;
            }
            pnetwork->retrieveInterfaceInfo();
            content[0].append(pnetwork->mname).append("      ip:");
            content[1] = pnetwork->minterfaceAddress;
            content[2].append("mac:").append(pnetwork->mmacAddress);
            content[3].append("data:").append(UNKNOWN_INFORMATION);
        }
        screen.show(&content[0], &content[1], &content[2], &content[3]);
    }

}
